Plot KAZR data with Proper

Plot KAZR data with ProperΒΆ

import pyart
import xarray as xr
from distributed import LocalCluster, Client
import glob
import hvplot.xarray
import holoviews as hv
from bokeh.models import HoverTool
cluster = LocalCluster()
client = Client(cluster)
client
2022-03-22 22:53:33,532 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-uqj_sb1s', purging
2022-03-22 22:53:33,533 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-m2wxo13m', purging
2022-03-22 22:53:33,533 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-7la94o81', purging
2022-03-22 22:53:33,534 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-b4qv_1fd', purging

Client

Client-cf9a1946-aa5c-11ec-8d1e-acde48001122

Connection method: Cluster object Cluster type: distributed.LocalCluster
Dashboard: http://127.0.0.1:8787/status

Cluster Info

files = sorted(glob.glob('../../data/kazr/houkazrcfrgeM1.a1.20220315*'))
def plot_kazr(ds, max_height):
    ds['time'] = ds.time.astype(int)/10**6
    
    ref = ds.reflectivity.compute()
    vel = ds.mean_doppler_velocity.compute()
    
    max_height = 9000
    ref_plot = ref.compute().hvplot.quadmesh(x='time', 
                                             y='range',
                                             rasterize=True,
                                             cmap='pyart_HomeyerRainbow',
                                             ylim=(0, max_height),
                                             height=300,
                                             width=700,
                                             clim=(-20, 40),
                                             label='Reflectivity (dBZ)',
                                             xlabel='Date (UTC)',
                                             hover=True).opts(hooks=[apply_formatter])

    vel_plot = vel.compute().hvplot.quadmesh(x='time', 
                                             y='range',
                                             rasterize=True,
                                             cmap='pyart_balance',
                                             ylim=(0, max_height),
                                             height=300,
                                             width=700,
                                             clim=(-8, 8),
                                             label='Velocity (m/s)',
                                             xlabel='Date (UTC)',
                                             hover=True).opts(hooks=[apply_formatter])
    
    return (ref_plot + vel_plot).cols(1)
    
ds = xr.open_mfdataset(files,
                       use_cftime=True,
                       chunks={'time':2000})
ds['time'] = ds.indexes['time'].to_datetimeindex()
/Users/mgrover/opt/anaconda3/envs/tracer-dev/lib/python3.9/site-packages/xarray/coding/times.py:351: FutureWarning: Index.ravel returning ndarray is deprecated; in a future version this will return a view on self.
  sample = dates.ravel()[0]
ds['time'] = ds.time.astype(int)/10**6
from bokeh.models import DatetimeTickFormatter

def apply_formatter(plot, element):
    plot.handles['xaxis'].formatter = DatetimeTickFormatter(hours='%m/%d/%Y \n %H:%M',
                                                            minutes='%m/%d/%Y \n %H:%M',
                                                            hourmin='%m/%d/%Y \n %H:%M')
ref = ds.reflectivity.compute()
vel = ds.mean_doppler_velocity.compute()
max_height = 9000
ref_plot = ref.compute().hvplot.quadmesh(x='time', 
                                         y='range',
                                         rasterize=True,
                                         cmap='pyart_HomeyerRainbow',
                                         ylim=(0, max_height),
                                         height=300,
                                         width=700,
                                         clim=(-20, 40),
                                         label='Reflectivity (dBZ)',
                                         xlabel='Date (UTC)',
                                         hover=True).opts(hooks=[apply_formatter])

vel_plot = vel.compute().hvplot.quadmesh(x='time', 
                                         y='range',
                                         rasterize=True,
                                         cmap='pyart_balance',
                                         ylim=(0, max_height),
                                         height=300,
                                         width=700,
                                         clim=(-8, 8),
                                         label='Velocity (m/s)',
                                         xlabel='Date (UTC)',
                                         hover=True).opts(hooks=[apply_formatter])
(ref_plot + vel_plot).cols(1)
lon, lat = ds.lon.values[0], ds.lat.values[0]
print(lat, lon)
29.670000076293945 -95.05899810791016